# 导包
import requests


class SendMethod:
    @staticmethod
    def send_method(method, url, params=None, data=None):
        if method == "post":
            resp = requests.post(url, data=data)
        elif method == "get":
            resp = requests.get(url, params=params)
        else:
            resp = None
            print("不支持该请求")

        result = {}
        if resp is not None:
            result["status_code"] = resp.status_code
            result["headers"] = resp.headers
            result["body"] = resp.json()
            result["requests_time"] = int(resp.elapsed.microseconds / 1000)
            return result
        else:
            return resp


if __name__ == '__main__':
    #  请求行
    url = "http://127.0.0.1:8000/api/add_event/"
    #  请求体
    body = {
        "eid": "888",
        "name": "爱拼才会赢把",
        "limit": "20",
        "status": "1",
        "address": "武汉源码时代",
        "start_time": "2022-07-25"
    }
    sm = SendMethod().send_method("post", url, data=body)
    print(sm)
